Repository navigation
trystero: the negotiating room counts as advertised, so a page whose first frames Chrome dropped is bound again - #11
Merged
Conversation
…remote's advertisement, so that a page whose first frames Chrome dropped is bound again after the handshake times out The interop lane's "one room leaving" scenario failed on main (run 47519299767, 1 of 13 runs): the C++ peer, the lower id, offered in both rooms, and the page answered. Chrome drops what a page sends on an answering channel as it opens, and the page's presence and its @_hsready of the first room were lost. The C++ first room, bound to the connection by its own negotiation, never heard the page's readiness, timed the handshake out after 10 s and kicked the page from the room. Its rebinding over the live connection binds only a room the remote advertised, by its presence or by a kept frame of the room; a Trystero JS page advertises a room once per connection and, kicked from it, sends nothing more of it, so the first room never came back while the second went on. A connection now records the token of the room whose negotiation opened it as the remote's advertisement from the start: the remote answered or offered in that room's signaling. The app records it only on the connection it adopts, a held second connection keeps it for when it replaces the first, and the existing connection returned for another negotiation does not take it, since another remote may have answered that negotiation in the peer's name. After the kick, the rebinding (11 s) sends the room's presence, the page binds the room again, and both handshakes pass. The interop test gains the scenario "The page losing its first frames on the connection still joins both rooms": js.html's drop-early-sends drops what the page sends on the first channel it accepts for 300 ms, and the page joins room2 2 s later. It failed 7 runs of 7 before the change (room first never back in 30 s) and passed 20 runs of 20 after, in 21 s; the full browser interop passed 27 scenarios of 27, and "one room leaving" 10 runs of 10. Unit tests cover the advertisement on a started connection and on adoption, a held second, and its replacement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The flake
Main CI run 47519299767 (head 658fe6f) failed the browser interop scenario "One room leaving, either side, leaves the other room and the connection". It failed 1 of the 13 emscripten interop runs on record; the native lane does not run it.
Root cause
The C++ peer, the lower id, offered in both rooms, and the page answered. Chrome drops what a page sends on an answering channel as it opens ("Send failed INVALID_STATE"). Here it dropped the page's presence and its
@_hsreadyfor the first room. The C++ first room had been bound by its own negotiation, so it never heard the page was ready: it timed the handshake out after 10 s and kicked the page.Its rebinding over the live connection binds only a room the remote has advertised, by its presence or by a kept frame. A Trystero JS page advertises a room once per connection and, once kicked from it, sends nothing more of that room. The first room never came back, while the second went on.
Fix
A connection records the token of the room whose negotiation opened it as the remote's advertisement from the start, since the remote answered or offered in that room's signaling. Only the connection the app adopts records it. A held second connection keeps its own token for when it replaces the first. The existing connection returned for another negotiation does not take that negotiation's token, since another remote may have answered in the peer's name.
After the kick, the rebinding (11 s) sends the room's presence, the page binds the room again, and both handshakes pass. No timeout changed.
Proof
js.html's newdrop-early-sendsdrops the page's sends on the first channel it accepts for 300 ms, and the page joins room2 2 s later. This reproduces the CI state exactly: one connection, room second active, room first timed out at 10 s.🤖 Generated with Claude Code